{% extends 'base.html' %}
{% block main %}
<nav class="navbar navbar-default" role="navigation">
    <div class="navbar-header">
         <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button> <a class="navbar-brand" href="#"><span class="glyphicon glyphicon-user"></span>&nbsp;地址管理</a>
    </div>
</nav>
    <form action="" method="post">
			{% csrf_token %}
                <input type="hidden" name="type_baocun" value="baocun"/>
                <input type="hidden" name="tel"/>
                <input type="hidden" name="pro"/>
                <input type="hidden" name="city"/>
                <input type="hidden" name="area"/>
                <input type="hidden" name="address_all"/>
            </form>
    <table style="width: 100%;" border="1" cellspacing="0" cellpadding="0">
				<thead>
					<tr align="center" style="font-weight:bold;">
						<td>
							用户名
						</td>
						<td>
							联系电话
						</td>
						<td>
							配送地址
						</td>
					</tr>
				</thead>
				<tbody>


					<tr align="center" style="height: 50px">
						<td>
							{{ user.username }}
						</td>
						<td>
                            {% if user.address == '0' %}

                            <input placeholder="请输入11位数字手机号" name="phone" style="width: 250px;height: 30px;font-size: 16px" type="text" id="dh"/>

                            {% else %}
                            {{ user.tel }}
                        {% endif %}
                        </td>
						<td>
                            {% if user.address == '0' %}
                            <b>省:</b>
                            <select id="pro">
                                {% for foo in pro %}
                                    <option value="{{ foo.id }}">{{ foo.name }}</option>
                                {% endfor %}
                            </select>
                            <b>市:</b>
                            <select id="city">
                                {% for foo in city %}
                                    <option value="{{ foo.id }}">{{ foo.name }}</option>
                                {% endfor %}
                            </select>
                            <b>县:</b>
                            <select id="area">
                                {% for foo in area %}
                                    <option value="{{ foo.id }}">{{ foo.name }}</option>
                                {% endfor %}
                            </select>
                                <br>

                            {% else %}
                            {{ user.address }}
                        {% endif %}
                        </td>
                        {% if user.address == '0' %}
                            <tr>
                                <td align="center" style="font-weight:bold;">
                                    详细地址：
                                </td>
                            <td colspan="10">
                                <textarea id="address_all" placeholder="请输入:乡镇-街道-门牌号" style="width: 100%;height: 100px;font-size: 15px;"></textarea>
                            </td>
                         {% endif %}
					        </tr>
				</tbody>
			</table>
    <br>
    {% if user.address == '0' %}
    <a id="submit" href="/logreg/user_data/"><button type="button" class="btn btn-default btn-block btn-info"><span class="glyphicon glyphicon-ok"></span>&nbsp;保存地址</button></a>
    {% else %}
    <a href="/logreg/user_del/"><button type="button" class="btn btn-default btn-block btn-info"><span class="glyphicon glyphicon-cog"></span>&nbsp;修改地址</button></a>
    {% endif %}
    <br>
    <a id="submit" href="/"><button type="button" class="btn btn-block btn-success"><span class="glyphicon glyphicon-home"></span>&nbsp;去点餐</button></a>
{% endblock main %}